package net.kucoe.grin.sample.printing;

import net.kucoe.grin.*;
import net.kucoe.grin.System;
import net.kucoe.grin.utils.ResultFuture;

/**
 * System for printing.
 * 
 * @author Vitaliy Basyuk
 */
@System
public class PrintingSystem {
    
    @Actor
    protected Printer printer;
    @Space
    protected Console console;
    
    /**
     * Prints string passed.
     * 
     * @param string
     * @return {@link PrintedString}
     */
    @Strategy(Printer.class)
    public PrintedString print(final String string) {
        console.put(string);
        ResultFuture<PrintedString> resultFuture = new ResultFuture<PrintedString>(PrintedString.class, string);
        return resultFuture.getResult();
    }
    
    @Validator
    protected boolean validatePrint(final PrintedString string) {
        return string != null && string.printed == true;
    }
    
}
